package com.ycsj.goldmedalnewconcept.common.util;

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.ycsj.common.manager.PopUpManager;
import com.ycsj.goldmedalnewconcept.R;

/**
 * 退出登录的弹框
 * Created by Administrator on 2019/4/12 0012.
 */

public class ExitPopUtils {

    /**
     * 弹出退出登录的对话框
     *
     * @param context
     * @param activity
     */
    public static void showExitPop(Context context, Activity activity, final OnExitListener listener) {
        PopUpManager.showPopByMatchParent(context, R.layout.pop_common_delete, 0.3f, activity, new PopUpManager.onGetViewListener() {
            @Override
            public void getChildView(View view, int layoutResId) {
                TextView tvMsg = view.findViewById(R.id.txt_msg);
                tvMsg.setText("确定退出登录吗?");

                //取消按钮
                Button btCancel = view.findViewById(R.id.btn_neg);
                btCancel.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        PopUpManager.dismiss();
                    }
                });

                //确定按钮
                Button btOk = view.findViewById(R.id.btn_pos);

                btOk.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        PopUpManager.dismiss();
                        if (listener != null) {
                            listener.onExitOk();
                        }
                    }
                });
            }
        });
    }


    /**
     * 回调接口
     */
    public interface OnExitListener {
        void onExitOk();
    }


}
